package Backtracking;
/*
* 494. 目标和
*
* */
public class FindTargetSumWays494 {
    int count=0;
    public int findTargetSumWays(int[] nums, int s) {
        backtrack(nums,s,0,0);
        return count;
    }

    private void backtrack(int[] nums, int s, int sum, int index) {
        if(index==nums.length){
            if(sum==s){
                count++;
            }
        }else {
            backtrack(nums, s, sum+nums[index], index+1);
            backtrack(nums, s, sum-nums[index], index+1);
        }

    }
}
